package com.yifi.system.service;

import com.yifi.common.DBHelper;
import com.yifi.common.wx.WeixinUtil;
import com.yifi.common.wx.WxSendMsg;

public class WeiXinService {

	public static int SendMsg(String wx_userid,String wx_content)
	{
		String sql="select cvalue from sys_option where ccode='CorpID'";
		String corpId=DBHelper.GetString(sql);
		sql="select cvalue from sys_option where ccode='Secret'";
		String secret=DBHelper.GetString(sql);
		sql="select cvalue from sys_option where ccode='AgentId'";
		String agentid=DBHelper.GetString(sql);
		
		//String access_token = WeixinUtil.getAccessToken(ParamesAPI.corpId, ParamesAPI.secret).getToken();
		String access_token = WeixinUtil.getAccessToken(corpId, secret).getToken();
		
		 String PostData = WxSendMsg.STextMsg(wx_userid, "@all", "@all",agentid, wx_content);
		 int result = WeixinUtil.PostMessage(access_token, "POST", PostData);
		 return result;
	}
}
